<template>
  <div>
    <ul class="list_box">
      <li 
        v-for="(item, index) in list" 
        :key="index" 
        @click="loginSwitch(index)"
        :class="[currentIndex === index? 'list_active':'']">
        {{item}}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: ['登陆', '注册'],
      currentIndex: 0,
    }
  },
  methods: {
    loginSwitch(index) {
      this.currentIndex = index
      this.$emit('login-switch', index)
    }
  },
}
</script>

<style lang="less" scoped>
.list_box {
  display: flex;
  font-size: .426667rem;
  font-weight: 500;
  color: #222222;
  li {
    line-height: 2.266667rem;
    flex: 1;
    text-align: center;
  }
}

.list_active {
  position: relative;
  font-size: .56rem;
  font-weight: bold;
}

.list_active::before {
  content: "";
  position: absolute;
  bottom: .533333rem;
  left: 50%;
  transform: translateX(-50%);
  width: .746667rem;
  height: .08rem;
  background: #FF5543;
}
</style>